//
//  WeSellerMeesageInputView.m
//  WeGalaxy
//
//  Created by Zheng on 2017/7/24.
//  Copyright © 2017年 Zheng. All rights reserved.
//

#import "WeSellerMeesageInputView.h"
#import "WeAuctionPublichTextView.h"

@implementation WeSellerMeesageInputView

- (void)textViewDidEndEditing:(UITextView *)textView {
    if (textView.hasText) {
        _msgBlock(textView.text);
        textView.text = nil;
        _inputTxtv.placeHolderLbl.hidden = NO;
    } else {
        _inputTxtv.placeHolderLbl.hidden = YES;
    }
    
}


- (void)textViewDidChange:(UITextView *)textView {
    if (textView.hasText) {
        _inputTxtv.placeHolderLbl.hidden = YES;
    } else {
        _inputTxtv.placeHolderLbl.hidden = NO;
    }
}

- (instancetype)init {
    self = [super init];
    if (self) {
        [self addSubview:self.voiceBtn];
        [self addSubview:self.lineView];
        [self addSubview:self.inputTxtv];
        
        [_voiceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.left.equalTo(self);
            make.width.height.mas_equalTo(55);
        }];
        
        [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.right.equalTo(self);
            make.height.mas_equalTo(0.7);
        }];
        
        [_inputTxtv mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_voiceBtn.mas_right).offset(3);
            make.right.mas_equalTo(-20);
            make.bottom.equalTo(self);
            make.top.equalTo(@15);
        }];
    }
    return self;
}

- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [UIView new];
        _lineView.backgroundColor = kRGB_COLOR(200, 199, 204, 1);
    }
    return _lineView;
}

- (UIButton *)voiceBtn {
    if (!_voiceBtn) {
        _voiceBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _voiceBtn.backgroundColor = [UIColor orangeColor];
    }
    return _voiceBtn;
}

- (WeAuctionPublichTextView *)inputTxtv {
    if (!_inputTxtv) {
        _inputTxtv = [[WeAuctionPublichTextView alloc] init];
        _inputTxtv.placeHolderLbl.text = @"想对Ta说点什么";
        _inputTxtv.top = 5.5f;
        _inputTxtv.delegate = self;
    }
    return _inputTxtv;
}




@end
